from random import random, randint
#100以内除三
for i in range(1, 100+1):
    if i % 3 == 0 and i % 7 == 0:
        print(i)
#猜数字
#产生随机数
num = randint(1,30)
while True:
    guess = int(input("Guess a number between 1 and 100: "))
    if guess==num:
        print("Correct!")
        break
    if guess<num:
        print("Too low!")
    if guess>num:
        print("Too high!")

# #打印99乘法表
for i in range(1, 9 + 1):
    for j in range(1, i + 1):
        print("%i*%i=%i" % (j,i,i*j), end="\t")
    print()

# #打印水仙花数
for i in range(999):
    a=int(i%100%10)# 个位数
    b=int(i%100/10)# 十位数
    c=int(i/100)# 百位数
    # print(a,b,c)
    if ((i == a * a * a + b * b * b + c * c * c) and i != 0 and i != 1):
        print(i)

# #打印100以内的质数
for num in range(0, 100):
    if num > 1:  # 质数定义为大于1的自然数
        state = True  # 假设当前数字是质数
        for i in range(2, int(num ** 0.5) + 1):
            if num % i == 0:
                state = False  # 如果找到因数，则不是质数
                break
        if state:
            print(num, end=' ')  # 如果是质数，则打印

# #打印100以内的完数
for i in range(1, 100+1):
    sum = 0
    for j in range(1, i):
        if (i % j == 0):  # 如果j是i的因子
            sum += j
            # print(sum)
    if sum == i:
        print(i)

# #打印斐波那契数列前30
# 初始化斐波那契数列的前两个数字
a, b = 0, 1
count = 0
while count < 39:
    print(a, end=' ')
    # 更新斐波那契数列的下一个数字
    a=b
    b=a+b
    count += 1

#打印菱形
for i in range(1, 11 + 1, 2):
    print(("*" * i).center(11))
for i in range(9, 0, -2):
    print(("*" * i).center(11))

